﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyPSDALayer;
using MyPS.Models;

namespace MyPS.Controllers
{
    public class HomeController : Controller
    {
        private MyPSEntities db = new MyPSEntities();
        //
        // GET: /Home/         
        public ActionResult Index()
        {
            IndexModel mode = new IndexModel();
            mode.ArticleList = db.Articles.Where(o => o.ISIndex == "Y").Select(o => new V_Article { ID = o.ArticleID, Name = o.ArticleName }).Take(8).ToList();
            mode.CaseList = db.CaseBases.Where(o => o.IsIndex == "Y").Select(o => new V_Case { ID = o.CaseID, CoverUrl = o.CoverUrl, Name = o.CaseName }).Take(8).ToList();
            mode.TeamList = db.TopTeams.Where(o => o.ISIndex == "Y").Select(o => new V_TopTeam { ID = o.ID, CoverUrl = o.CoverUrl, Name = o.TeamName }).ToList();
            return View(mode);
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
